package com.wzy.order.controller;

import com.wzy.orderapi.model.dto.OrderDto;
import org.springframework.web.bind.annotation.*;

import java.util.Collection;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@RestController
@RequestMapping("order")
public class OrderController {

    public static  final Map<String,OrderDto> datas = new ConcurrentHashMap<>();

    @PostMapping("save")
    public boolean saveOrder(@RequestBody OrderDto orderDto){
        datas.put(orderDto.getId(), orderDto);
        return true;
    }

    @GetMapping("findAll")
    public Collection<OrderDto> findAll() throws InterruptedException {
        Thread.sleep(2000L);
        return datas.values();
    }
}
